@isTest
private class TransferProductControllerTest {
    static testMethod void testMethod1() {
        Product__c p1 = TestUtils.createInst();
        insert p1;
        Product__c p2 = TestUtils.createInst();
        insert p2;

        Account acc = TestUtils.createAccount();
        insert acc;

        Equipment__c cp = new Equipment__c();
        cp.Account__c = acc.Id;
        cp.Product__c = p1.Id;
        insert cp;



        // ------------测试开始-----------
        TransferProductController tp = new TransferProductController();
        tp.init();

        tp.searchObjctStr = 'Product__c';
         tp.searchObjName();

        Map<String,Object> searchMap = new Map<String,Object>();
        searchMap.put('objApi', 'Equipment__c!Product__c');
        searchMap.put('oldId', p1.Id );
        tp.searchObjctStr = EncodingUtil.urlEncode(JSON.serialize(searchMap), 'UTF-8');
        tp.searchData();
        searchMap.put('newId', p2.Id  );
        searchMap.put('limit', '1' );

        tp.searchObjctStr = EncodingUtil.urlEncode(JSON.serialize(searchMap), 'UTF-8');
        tp.transfer2();


        searchMap.put('oldId', p2.Id );
        searchMap.put('newId', p1.Id  );

        Map<String,String>data = new Map<String,String>();
        data.put('id',p1.Id );
        searchMap.put('data', data );
        tp.searchObjctStr = EncodingUtil.urlEncode(JSON.serialize(searchMap), 'UTF-8');
        tp.transfer1();

    }
}